import { login_service as request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(response: ResultType) {
  if (response.result.resultCode == '000000') {
    return response.data
  }
  throw new Error()
}

//登录接口
export const login = (params?: any) =>
  request.post(`user/login`, params).then((res: any) => adapter(res as any))
